/* -----------------------------------------------------
 iCompose
 MainView.h
 
 Created by Team: THE BEARD on 18/10/09
 Members who contributed to this file:
 1. Ethan Holmes
 
 Simon Fraser University, 2009.
 ----------------------------------------------------- */

#import <UIKit/UIKit.h>
#import "iComposeAppDelegate.h"
#import "Staff.h"
#import "MainOptionsView.H"

#define kMinimumGestureLength       50 
#define kMaximumVariance            10

@interface MainView : UIViewController <UIScrollViewDelegate, AVAudioPlayerDelegate, NSCoding> {
	Staff *staff;
	CGPoint gestureStartPoint;
	CGPoint lastPosition;
	UIView* currentBarView;
	UIView *lastPitchView;
	UIView *lastPositionView;
	UIImageView *noteImage;
	//UIScrollView *barViews;
	AVAudioPlayer *samplePlayer;
	UIView *isPlayingSample;
	
	// Pitch views.
	IBOutlet UIView *C1;
	IBOutlet UIView *D1;
	IBOutlet UIView *E1;
	IBOutlet UIView *F1;
	IBOutlet UIView *G1;
	IBOutlet UIView *A1;
	IBOutlet UIView *B1;
	IBOutlet UIView *C2;
	IBOutlet UIView *D2;
	IBOutlet UIView *E2;
	IBOutlet UIView *F2;
	IBOutlet UIView *G2;
	IBOutlet UIView *A2;
	
	// Eighth note views.
	NodeView *eighth1View;
	NodeView *eighth2View;
	NodeView *eighth3View;
	NodeView *eighth4View;
	NodeView *eighth5View;
	NodeView *eighth6View;
	NodeView *eighth7View;
	NodeView *eighth8View;
	
	// Quarter note views.
	NodeView *quarter1View;
	NodeView *quarter2View;
	NodeView *quarter3View;
	NodeView *quarter4View;
	
	// Half notes views.
	NodeView *half1View;
	NodeView *half2View;
	
	// Whole note view.
	NodeView *wholeView;
	
	
	NSMutableArray *staffList;
	NSMutableArray *pitchList;
	
	NSMutableArray *eighthList;
	NSMutableArray *quarterList;
	NSMutableArray *halfList;
	
	IBOutlet UIView *staffBox;
	IBOutlet UIButton *wholeButton;
	IBOutlet UIButton *halfButton;
	IBOutlet UIButton *quarterButton;
	IBOutlet UIButton *eighthButton;
	IBOutlet UIButton *infoButton;
	IBOutlet UILabel *barLabel;
	IBOutlet UIView *noteBox;
}

@property (nonatomic, retain) Staff *staff;
@property (nonatomic) CGPoint gestureStartPoint;
@property (nonatomic) CGPoint lastPosition;
@property (nonatomic, retain) UIView* currentBarView;
@property (nonatomic, retain) UIView *lastPitchView;
@property (nonatomic, retain) UIView *lastPositionView;
@property (nonatomic, retain) UIImageView *noteImage;
//@property (nonatomic, retain) UIScrollView *barViews;
@property (nonatomic, retain) AVAudioPlayer *samplePlayer;
@property (nonatomic, retain) UIView *isPlayingSample;

@property (nonatomic, retain) IBOutlet UIView *C1;
@property (nonatomic, retain) IBOutlet UIView *D1;
@property (nonatomic, retain) IBOutlet UIView *E1;
@property (nonatomic, retain) IBOutlet UIView *F1;
@property (nonatomic, retain) IBOutlet UIView *G1;
@property (nonatomic, retain) IBOutlet UIView *A1;
@property (nonatomic, retain) IBOutlet UIView *B1;
@property (nonatomic, retain) IBOutlet UIView *C2;
@property (nonatomic, retain) IBOutlet UIView *D2;
@property (nonatomic, retain) IBOutlet UIView *E2;
@property (nonatomic, retain) IBOutlet UIView *F2;
@property (nonatomic, retain) IBOutlet UIView *G2;
@property (nonatomic, retain) IBOutlet UIView *A2;

@property (nonatomic, retain) NodeView *eighth1View;
@property (nonatomic, retain) NodeView *eighth2View;
@property (nonatomic, retain) NodeView *eighth3View;
@property (nonatomic, retain) NodeView *eighth4View;
@property (nonatomic, retain) NodeView *eighth5View;
@property (nonatomic, retain) NodeView *eighth6View;
@property (nonatomic, retain) NodeView *eighth7View;
@property (nonatomic, retain) NodeView *eighth8View;

@property (nonatomic, retain) NodeView *quarter1View;
@property (nonatomic, retain) NodeView *quarter2View;
@property (nonatomic, retain) NodeView *quarter3View;
@property (nonatomic, retain) NodeView *quarter4View;

@property (nonatomic, retain) NodeView *half1View;
@property (nonatomic, retain) NodeView *half2View;

@property (nonatomic, retain) NodeView *wholeView;

@property (nonatomic, retain) NSMutableArray *staffList;
@property (nonatomic, retain) NSMutableArray *pitchList;

@property (nonatomic, retain) NSMutableArray *eighthList;
@property (nonatomic, retain) NSMutableArray *quarterList;
@property (nonatomic, retain) NSMutableArray *halfList;

@property (nonatomic, retain) IBOutlet UIView *staffBox;
@property (nonatomic, retain) IBOutlet UIButton *eighthButton;
@property (nonatomic, retain) IBOutlet UIButton *wholeButton;
@property (nonatomic, retain) IBOutlet UIButton *halfButton;
@property (nonatomic, retain) IBOutlet UIButton *quarterButton;
@property (nonatomic, retain) IBOutlet UIButton *infoButton;
@property (nonatomic, retain) IBOutlet UILabel *barLabel;
@property (nonatomic, retain) IBOutlet UIView *noteBox;
//@property (nonatomic, retain) IBOutlet UIPageControl *pageControl;

-(void)initStaffState:(TimeSignature*)time andTempo:(Tempo*)speed andInstrument:(InstrumentPlayer*) player andName:(NSString*)name;
-(void)initStaff:(Staff*)newStaff;
-(IBAction)saveStaff;
-(IBAction)play;
-(IBAction)stop;
-(void)clearViews;
-(void)removeImageView;
-(int)getPitch:(CGPoint)location ;
-(NodeView*)getView:(NSMutableArray*)list withPoint:(CGPoint)location;
-(void)highlightStaff:(CGPoint)location withList:(NSMutableArray*)list andType:(int)type;
-(void)highlightSelected:(int)position withPoint:(CGPoint)location;
-(void)setAlphas:(NoteNode*)currView;
-(IBAction)infoButtonPressed:(id)sender;
-(UIImage*)getImage:(int)position;
-(UIView*)getCurrentBarView;
-(void)playSample:(UIView *)pitch;

@end
